import django_filters
from rest_framework import filters
from django_filters.rest_framework import DjangoFilterBackend

from activities.models import *


class ActivityDataFilter(django_filters.rest_framework.FilterSet):
    '''邮米派发过滤'''

    create_time_begin = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='gte')
    create_time_end = django_filters.DateTimeFilter(field_name="create_time__date", lookup_expr='lte')
    state = django_filters.BaseInFilter(field_name='state', lookup_expr='in')
    activity = django_filters.BaseInFilter(field_name='activity_id', lookup_expr='in')
    companyuser_id = django_filters.BaseInFilter(field_name='companyuser_id', lookup_expr='in')

    class Meta:
        model = ActivityData
        fields = ('create_time_begin', 'create_time_end', 'companyuser_id', 'state')


class ChannelFilter(django_filters.rest_framework.FilterSet):

    channel_type = django_filters.BaseInFilter(field_name='channel_type', lookup_expr='in')

    class Meta:
        model = Channel
        fields = ('channel_type',)